package site.shenjie.spring.rest.template.controller;

import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.*;
import site.shenjie.spring.rest.template.entity.HouseInfo;

/**
 * 沈杰
 * 2020-7-24 09:39:02
 * 控制器：
 */
@RestController
public class HouseController {
    @RequestMapping("/house/data")
    public HouseInfo getData(@RequestParam("name") String name) {
        return new HouseInfo(1L,name,"中国·云南");
    }

    @RequestMapping("/house/data/{name}")
    public String getData2(@PathVariable("name") String name) {
        return name;
    }

    @PostMapping("/house/save")
    public Long addData(@RequestBody HouseInfo houseInfo) {
        System.out.println(JSONObject.toJSONString(houseInfo));
        return 1001L;
    }
}
